<template>
  <div>
    <template v-if="dict.length > 0">
      <template v-if="dict.length < 6">
        <el-radio-group v-model="bindVal">
          <el-radio v-for="item in dict" :key="item.val" :label="item.val">{{
            item.name
          }}</el-radio>
        </el-radio-group>
      </template>
      <template v-else>
        <com-select v-model="bindVal" :dictList="dict" :multiple="isMul" />
      </template>
    </template>
    <template v-else>
      <el-input v-model="bindVal" :placeholder="`请输入`" />
    </template>
  </div>
</template>
<script>
import ComSelect from "@/components/com-select/com-select.vue";
export default {
  components: {
    ComSelect,
  },
  props: {
    type: {
      type: String,
      default: "text",
    },
    modelValue: {
      type: [String, Number, Array, Object],
      default: "",
    },
    dict: {
      type: Array,
      default: () => [],
    },
  },
  computed: {
    isMul() {
      return this.bindVal instanceof Array;
    },
  },
  data() {
    return {
      bindVal: undefined,
    };
  },
  watch: {
    bindVal(val) {
      this.$emit("update:modelValue", val);
    },
  },
  mounted() {
    this.bindVal = this.modelValue;
  },
};
</script>
<style lang=""></style>
